#!/bin/bash

# Linux Brainfuck IDE 编译脚本

echo "编译 Brainfuck IDE for Linux..."

# 检查依赖
check_dependencies() {
    local deps=("g++" "cmake" "make")
    for dep in "${deps[@]}"; do
        if ! command -v $dep &> /dev/null; then
            echo "错误: 未找到 $dep，请安装:"
            echo "  Ubuntu/Debian: sudo apt install build-essential cmake"
            echo "  CentOS/RHEL: sudo yum groupinstall 'Development Tools' && sudo yum install cmake"
            echo "  Fedora: sudo dnf groupinstall 'Development Tools' && sudo dnf install cmake"
            exit 1
        fi
    done
}

# 创建构建目录
mkdir -p build
cd build

# 使用 CMake 配置
cmake ..

# 编译
make -j$(nproc)

if [ $? -eq 0 ]; then
    echo "编译成功!"
    echo "运行程序: ./bin/brainfuck_ide"
else
    echo "编译失败!"
    cd ..
    exit 1
fi

cd ..